working of dc generator